package com.whdh.demo01;

public class E {
    public static String[] main(String[] args) {
        C c = new C();
        args = charArrayConversion(c.read());
        return args;
    }

    /**
     * 判断是否为整数
     *
     * @param str
     * @return boolean
     */
    private static boolean isNumeric(String str) {

        for (int i = str.length(); --i >= 0; ) {

            int chr = str.charAt(i);

            if (chr < 48 || chr > 57) {
                return false;
            }
        }
        return true;
    }

    /**
     * 将接收的字符串数组去掉“,”号，并将其中的数字放入新的字符串数组中返回
     *
     * @param str 接收传递的字符串
     * @return String[] 返回字符串数组
     */
    private static String[] charArrayConversion(String str) {
        String[] stringList = str.split(",");
        String[] strings = new String[stringList.length];
        int j = 0;
        for (int i = 0; i < stringList.length; i++) {
            if (isNumeric(stringList[i])) {
                strings[j] = stringList[i];
                j++;
            }
        }
        return strings;
    }
}
